<template>
  <view class="team-member-item">
    <view class="member-info">
      <image :src="item.avatar" mode="aspectFill" class="avatar"></image>
      <view class="info">
        <view class="name-wrap">
          <text class="nickname">{{item.nickname}}</text>
          <text class="level" :style="levelStyle">{{levelName}}</text>
        </view>
        <text class="phone">{{item.phone}}</text>
      </view>
    </view>
    <view class="member-stats">
      <view class="stat-item">
        <text class="value">{{item.orderCount}}</text>
        <text class="label">订单数</text>
      </view>
      <view class="stat-item">
        <text class="value">¥{{item.commission}}</text>
        <text class="label">佣金</text>
      </view>
      <view class="stat-item">
        <text class="value">{{item.joinTime}}</text>
        <text class="label">加入时间</text>
      </view>
    </view>
  </view>
</template>

<script setup>
import { computed } from 'vue'
import { LEVEL_NAMES, LEVEL_ICONS } from '@/constants/distribution'

const props = defineProps({
  item: {
    type: Object,
    required: true
  }
})

const levelName = computed(() => {
  return LEVEL_NAMES[props.item.level] || '普通用户'
})

const levelStyle = computed(() => {
  return {
    backgroundImage: `url(${LEVEL_ICONS[props.item.level] || LEVEL_ICONS.default})`,
    backgroundSize: 'cover'
  }
})
</script>

<style lang="scss">
.team-member-item {
  background-color: #FFFFFF;
  margin-bottom: 20rpx;
  padding: 20rpx;
  
  .member-info {
    display: flex;
    align-items: center;
    margin-bottom: 20rpx;
    
    .avatar {
      width: 80rpx;
      height: 80rpx;
      border-radius: 40rpx;
      margin-right: 20rpx;
    }
    
    .info {
      flex: 1;
      
      .name-wrap {
        display: flex;
        align-items: center;
        margin-bottom: 10rpx;
        
        .nickname {
          font-size: 28rpx;
          color: #333;
          font-weight: bold;
          margin-right: 20rpx;
        }
        
        .level {
          width: 40rpx;
          height: 40rpx;
          border-radius: 20rpx;
        }
      }
      
      .phone {
        font-size: 24rpx;
        color: #999;
      }
    }
  }
  
  .member-stats {
    display: flex;
    justify-content: space-between;
    padding-top: 20rpx;
    border-top: 1rpx solid #EEEEEE;
    
    .stat-item {
      flex: 1;
      text-align: center;
      
      .value {
        font-size: 28rpx;
        color: #333;
        font-weight: bold;
        margin-bottom: 10rpx;
        display: block;
      }
      
      .label {
        font-size: 24rpx;
        color: #999;
      }
    }
  }
}
</style> 